use strict;

my $line;
my @hex_array;

my $file = $ARGV[0];
my $line_count = 0;

open( FILE, "<$file" ) or die "can't open $file";

my $count = 0;

print "char COFF_MATRIX[][20] = {\n";
while ( $line = <> )
{
	chomp $line;
	if ( $line =~ /TYPE/ )
	{
		$count++;

		if ( $count != 1 )
		{
			print ",\n";
		}

		my ( $junk1, $junk2, $pattern_in_hex, $junk3, $coff, $junk4, $junk5 ) = split / /, $line;

		$pattern_in_hex =~ s/;//;
		$coff =~ s/;//;

		push @hex_array, $pattern_in_hex;

		print "\t{ $coff }";
	}
}

print "\n};";

print "\n\n";

print "unsigned int PATTERN_MATRIX[] = {\n";

$count = 0;
for $line ( @hex_array )
{
	$count++;
	print "\t0x$line";

	if ( $count != scalar( @hex_array ) )
	{
		print ",\n";
	}
}

print "\n};";
